﻿using ReflectionStudio.Core.Events;
using System;
using System.Data;
using System.Windows;
using System.Windows.Data;
using System.ComponentModel;
namespace WPFExcelReport
{
    public partial class TSKD06
    {
        public TSKD06()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return; 
            MV = new VKUNDVER();
            this.DataContext = MV; 
            InitializeComponent();
         }
        public override void vwMaster_CurrentChanged(object sender, EventArgs e)
        {
            base.vwMaster_CurrentChanged(sender, e);
            if (dwMaster == null)
            {
                KEY = "";
            }
            else
            {
                KEY =TMV.KDVVG;
                ZAHLBED = TMV.KDVZAHLBED;
            }
        }

        public override void OnKUNDNRChg(string value)
        {
            if (!IsLoaded)
                return;
            TBMain.Clear();
            if (value.Trim().Length < 8)
            { //00000000
                return;
            }
            dwData = TBMain.NewRow();
            dwData["KDVMANDANT"] = app.Mandant;
            dwData["KDVKUNDNR"] = " AND KDVKUNDNR='" + value.Substring(0, 8) + "'";
            dwData["KDVVB"] =" AND KDVVB='"+ VB+"'";
            SResult = TMV.QKDV04(dwData);
            MergeData(SResult, false); 
        } 
        public override void ManageCommand(object sender, RoutedEventArgs e)
        {
            if (IsManage)
            {
                OnKUNDNRChg(KUNDNR);
            }
            else
            {
                VICC_WFEVENTS.SVWF.KD02(this.RUNID);
            }
            base.ManageCommand(sender, e);
        }

       
    }
}
